﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml.Serialization;
using BasicCMS.Data;

namespace BasicCMS.Modules
{
    /// <summary>
    /// 功能的组成项
    /// </summary>
    [Serializable]
    public class FeatureItem:Entity
    {
        private XElement _featureItemXml;

        public FeatureItem(XElement featureItemXml)
        {
            if (featureItemXml == null) throw new ArgumentNullException("featureItemXml is null!");

            _featureItemXml = featureItemXml;
            Url = _featureItemXml.Attr("url");
            Action = _featureItemXml.Attr("action");
            Path = FeatureInfo.GetPath(_featureItemXml.Parent);
        }

        /// <summary>
        /// Url地址
        /// </summary>
        [XmlAttribute("url")]
        public string Url { get; set; }

        /// <summary>
        /// 动作
        /// </summary>
        [XmlAttribute("action")]
        public string Action { get; set; }

        /// <summary>
        /// 组织结构路径
        /// </summary>
        [XmlIgnore]
        public string Path { get; set; }
    }
}
